package world.member.dao;

import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import world.member.domain.Member;

@Repository //==memberDAOImpl
public class MemberDAOImpl implements MemberDAO {
	
	@Resource
	private SqlMapClientTemplate sqlMap;

	public MemberDAOImpl(){}
	/*	setter
	public void setSqlMap(SqlMapClientTemplate sqlMap) {
		this.sqlMap = sqlMap;
	}
	*/
	//회원가입
	@Override
	public void joinMember(Member m) throws SQLException{
		
		sqlMap.insert("joinMember",m);	//insert 랑 select 동시에 가능?
	}
	//ID체크
	@Override
	public Member memberById(String id) throws SQLException {
		Member member = (Member) sqlMap.queryForObject("memberById",id);
		return member;
		//queryForObject == 하나의 값만 받아옴
	}
	//닉네임 체크
	@Override
	public Member nickNameCheck(String nickName) throws SQLException {
		Member member = (Member) sqlMap.queryForObject("memberByNickName",nickName);
		return member;
	}
	
	
	//회원정보 수정
	@Override
	public void updateMember(Member member) throws SQLException {
		sqlMap.update("updateMember",member);
		
	}
	
	//회원 탈퇴
	@Override
	public void updateLeave(Member member) throws SQLException {
		sqlMap.update("updateLeave",member);
	}
	
	
	/*
	@Override
	public ArrayList<Member> idCheck(String idCheck) throws SQLException {
		ArrayList<Member> list = (ArrayList<Member>) sqlMap.queryForList("memberList");
		return list;
	}
	*/
	
	
	
	
	
	
	
	
}
